package com.future.hedongjun.mine.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.future.hedongjun.R;
import com.future.hedongjun.mine.bean.DeliveryAddressBean;

import java.util.List;


/**
 * Created by gxcheng on 2017/9/14.
 * 收货地址适配器
 */

public class DeliveryAddressAdapter extends BaseQuickAdapter<DeliveryAddressBean, BaseViewHolder> {

    public DeliveryAddressAdapter(@LayoutRes int layoutResId, @Nullable List<DeliveryAddressBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DeliveryAddressBean item) {
        helper.setText(R.id.delivery_address_user_name_tv, item.getName());
        if (Integer.parseInt(item.getIsdefault()) == 1) {
            helper.getView(R.id.delivery_address_default_str_tv).setVisibility(View.VISIBLE);
        }
        helper.setText(R.id.delivery_address_street_tv, item.getLocation() + item.getDetail());
        helper.setText(R.id.delivery_address_user_phone_tv, item.getPhone());
        helper.addOnClickListener(R.id.edit);
        helper.setVisible(R.id.line, helper.getAdapterPosition() != getItemCount() - 1);
    }

}
